<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>{$info.action}角色</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="__STATICS__/lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="__STATICS__/css/public.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <form class="layui-form" action="" lay-filter="form">
            <div class="layui-form-item">
                <label class="layui-form-label">账号</label>
                <div class="layui-input-inline">
                    <input type="text" name="name" lay-verify="name" autocomplete="off" placeholder="请输入账号" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">角色</label>
                <div class="layui-input-inline">
                  <select name="role_id" lay-filter="aihao">
                    {volist name="roleList" id="vo"}
                        <option value="{$vo.id}"  {if !empty($info.role_id) && $info.role_id==$vo.id}selected{/if}>{$vo.name}</option>
                    {/volist}
                  </select>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">密码</label>
                <div class="layui-input-inline">
                    <input type="text" name="password" lay-verify="pass" autocomplete="off" placeholder="请输入密码 为空不改变密码" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">是否有效</label>
                <div class="layui-input-block">
                    <input type="checkbox" checked="" name="status" lay-skin="switch" lay-filter="switchTest" lay-text="有效|无效">
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="submit">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>

    </div>
</div>

<script src="__STATICS__/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="__STATICS__/lib/jquery-3.4.1/jquery-3.4.1.min.js"></script>
<script>
    layui.use(['form'], function () {
        var form = layui.form;


        form.on('submit(submit)', function(data){

            loading =layer.load(1, {shade: [0.1,'#fff']});
            $.post("", data.field, function (res) {
                layer.close(loading);
                if (res.code > 0) {
                    layer.msg(res.msg, {time: 1800, icon: 1}, function () {
                       location.href = res.url;
                    });
                } else {
                    layer.msg(res.msg, {time: 1800, icon: 2});
                }
            });
            return false;
        });
        {notempty name="$info.name"}
        form.val("form", {
          "name": "{$info.name}",
          "status":{$info.status}
        });
        {/notempty}
    });
</script>

</body>
</html>